import os
import sys
from task.ui_test_task import UiAutoTest


def default(arguments):
    pass


def check_input(file_path: str):
    if os.path.splitext(file_path)[-1] not in ['.csv', '.xlsx']:
        raise Exception('文件格式错误 "{}"'.format(file_path))

    if not os.path.exists(file_path):
        raise FileNotFoundError('路径文件不存在 "{}"'.format(file_path))

    return os.path.splitext(file_path)[-1][1:]


if __name__ == '__main__':
    if len(sys.argv) == 2:
        file_path = sys.argv[1]
        check_input(file_path)
        UiAutoTest.run(file_path)
    else:
        task, operation = sys.argv[1:]
        from mobileagent.mobile_agent import MobileAgent

        ma = MobileAgent()
        ma.run(operation)